package com.bargate.domain.spring.expression;

import org.jetbrains.annotations.NotNull;

import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: EAD-MASTER
 * Date: 18/09/2010
 * Time: 23:33:12
 * To change this template use File | Settings | File Templates.
 */
public class Storm extends ABCComparator implements Comparable<Storm> {

	private String type;
	private Double maxWindVelocity;
	private Double distance = 0d;
	private Boolean isHarmful = false;
	private Date occurred;
	@NotNull private Storm currentRef;

	public Storm(String type) {
		this.type = type;
		currentRef = this;
	}

	public Date getOccurred() {
		return occurred;
	}

	public void setOccurred(Date occurred) {
		this.occurred = occurred;
	}

	public Storm(@NotNull String type, @NotNull Double maxWindVelocity,
	             Double distance, Boolean harmful) {
		this.type = type;
		this.maxWindVelocity = maxWindVelocity;
		this.distance = distance;
		isHarmful = harmful;
		currentRef = this;
	}

	public Storm(@NotNull String type, @NotNull Double maxWindVelocity,
	             Double distance, Boolean harmful, Date occurred) {
		this.type = type;
		this.maxWindVelocity = maxWindVelocity;
		this.distance = distance;
		isHarmful = harmful;
		this.occurred = occurred;
		currentRef = this;
	}

	public Storm(@NotNull String type, @NotNull Double maxWindVelocity, Boolean harmful) {
		this.type = type;
		this.maxWindVelocity = maxWindVelocity;
		isHarmful = harmful;
		currentRef = this;
	}

	public Storm(@NotNull String type, @NotNull Double maxWindVelocity,
	             Boolean harmful, Date occurred) {
		this.type = type;
		this.maxWindVelocity = maxWindVelocity;
		isHarmful = harmful;
		this.occurred = occurred;
		currentRef = this;
	}

	@NotNull
	public Storm getCurrentRef() {
		return currentRef;
	}

	public Double getDistance() {
		return distance;
	}

	public void setDistance(Double distance) {
		this.distance = distance;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Double getMaxWindVelocity() {
		return maxWindVelocity;
	}

	public void setMaxWindVelocity(Double maxWindVelocity) {
		this.maxWindVelocity = maxWindVelocity;
	}

	public Boolean getHarmful() {
		return isHarmful;
	}

	public void setHarmful(Boolean harmful) {
		isHarmful = harmful;
	}

	@Override
	public String toString() {
		return "\n==================================\n" +
				type +
				", maxWindVelocity:" + maxWindVelocity +
				", distance:" + distance +
				"\n" + "==================================\n";


	}

	public int compareTo(Storm storm) {
		if (getType().toCharArray()[0] == storm.getType().toCharArray()[0]) {
			if (getType().toCharArray()[1] == storm.getType().toCharArray()[1]) {
				return 0;
			} else if (getType().toCharArray()[1] < storm.getType().toCharArray()[1])
				return -1;
			else if (getType().toCharArray()[1] > storm.getType().toCharArray()[1])
				return 1;
			return 0;
		} else if (getType().toCharArray()[0] < storm.getType().toCharArray()[0])
			return -1;
		else if (getType().toCharArray()[0] > storm.getType().toCharArray()[0])
			return 1;
		return 0;
	}

}
                    
